<?php

require_once('query.php');

	$return_array = array();
	
	$term = $_GET['term'];
	
	$item = query('select *  where {
		   ?stop a transit:Stop.
		   ?stop rdfs:label ?stop_name.
		   FILTER (regex(str(?stop_name), "'.$term.'", "i"))
		}  LIMIT 5');
	
	$jsonStart = json_decode(strval($item), true);
	foreach($jsonStart['results']['bindings'] as $a){
		$row_array['value'] = $a['stop_name']['value'];
	
		array_push($return_array, $row_array);
	}
	echo json_encode($return_array);


die();
?>
